#!/bin/bash
INTERFACE="eth0"
RX_PREV=$(cat /sys/class/net/$INTERFACE/statistics/rx_bytes)
TX_PREV=$(cat /sys/class/net/$INTERFACE/statistics/tx_bytes)
sleep 10
RX_NEXT=$(cat /sys/class/net/$INTERFACE/statistics/rx_bytes)
TX_NEXT=$(cat /sys/class/net/$INTERFACE/statistics/tx_bytes)
echo "接收: $((($RX_NEXT - $RX_PREV)/1024)) KB/s"
echo "发送: $((($TX_NEXT - $TX_PREV)/1024)) KB/s"